package com.example.testgit.mapstruct;

import com.example.testgit.VO.BedVO;
import com.example.testgit.entity.BedDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.util.List;
@Mapper
public interface BedConverter {

    BedConverter INSTANCE = Mappers.getMapper(BedConverter.class);

    @Mappings({
            @Mapping(source = "bedType", target = "bedType", qualifiedByName = "typeTrans")
    })
    BedVO toVO(BedDO bedDO);

    @Mappings({
            @Mapping(source = "bedType", target = "bedType", qualifiedByName = "typeTrans")
    })
    List<BedVO> toVOList(List<BedDO> bedDOList);

    @Named("typeTrans")
    default String typeTrans(Integer bedType) {
        if (bedType.equals(0)) return "正常";
        else if (bedType.equals(1)) return "晚归";
        else return "未归";
    }
}
